package com.wc.alorithm_blue_bridge._模拟.躲炮弹;

import java.io.PrintWriter;
import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/5/23 1:39
 * @description https://www.lanqiao.cn/problems/17123/learning/
 */
public class Main {
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);
    static int n, l, r;

    public static void main(String[] args) {
        n = sc.nextInt();
        l = sc.nextInt();
        r = sc.nextInt();
        if (n >= l && n <= r) {
            int res = n - (l - 1);
            int dx = 1;
            while (check(r + dx)) {
                dx++;
            }
            res = Math.min(res, dx + r - n);
            out.println(res);
        } else {
            int step = 0;
            while (check(n + step) && check(n - step)){
                step++;
            }
            out.println(step);
        }
        out.flush();
    }

    static boolean check(int x) {
        for (int i = 1; i <= x / i; i++) {
            if (x % i == 0) {
                int y = x / i;
                if (x >= l && x <= r) return true;
                if (y >= l && y <= r) return true;
            }
        }
        return false;
    }
}

